package com.dingli.controller;

import com.dingli.framework.entity.Resume;
import com.dingli.framework.entity.Trainmember;
import com.dingli.framework.entity.Undertake;
import com.dingli.framework.util.Response;
import com.dingli.service.ITrainmemberService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/trainmember")
@Api(tags = "报名参与培训管理")
public class TrainmemberController {

    @Autowired
    private ITrainmemberService iTrainmemberService;

    @GetMapping("/TRselectList")
    @ApiOperation("报名参与培训表信息列表查询")
    public Response<PageInfo<Trainmember>> TRselectList(@ApiParam("查询条件")
                                                    @RequestParam(required = false) String search,
                                                        @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                                        @ApiParam("页面大小")
                                                    @RequestParam(required = false) Integer pageSize) {
        return iTrainmemberService.TRselectList(search, pageNum, pageSize);
    }

    @GetMapping("/TRselectAll")
    @ApiOperation("报名参与培训表信息详情查看")
    public Response<List<Trainmember>>TRselectAll(@ApiParam("报名参与培训表ID") @RequestParam Long tbId) {
        return iTrainmemberService.TRselectAll(tbId);
    }

    @PostMapping("/TRupdateState")
    @ApiOperation("报名参与培训表审核通过")
    public Response<Object> TRupdateState(@ApiParam("审核通过") @RequestBody String tbId) {

        return iTrainmemberService.TRupdateState(tbId);
    }

    @PostMapping("/TRupdate")
    @ApiOperation("报名参与培训表审核不通过")
    public Response<Object> TRupdate(@ApiParam("审核不通过") @RequestBody String tbId) {
        return iTrainmemberService.TRupdate(tbId);
    }

    @RequestMapping("/TRselect")
    @CrossOrigin
    @ApiOperation("报名参与查询所有不通过培训表")
    public HashMap<Object, Object> TRselect(@ApiParam("报名参与培训表不通过") @RequestParam String trId){
        Response<List<Trainmember>> list = iTrainmemberService.TRselect("123456");
        HashMap<Object, Object> trainmember = new HashMap<>();
        trainmember.put("trainmember",list);
        trainmember.put("size",list.getData().size());
        return trainmember;
    }

    @PostMapping("/TRinsert")
    @ApiOperation("报名参与培训信息新增")
    public Object TRinsert(@ApiParam("报名参与培训信息") @RequestBody Trainmember trainmember) {
        return iTrainmemberService.TRinsert(trainmember);
    }

    @PostMapping("/TRupdateById")
    @ApiOperation("报名参与培训信息修改")
    public Response<Object> TRupdateById(@ApiParam("修改报名参与培训信息") @RequestBody Trainmember trainmember) {

        return iTrainmemberService.TRupdateById(trainmember);
    }

    @GetMapping("/TRdeleteById")
    @ApiOperation("报名参与培训信息删除")
    public Response<Object> TRdeleteById(@ApiParam("报名参与培训ID") @RequestParam Long trId) {
        return iTrainmemberService.TRdeleteById(trId);
    }

}
